package testgaher;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 集合ArrayList的使用：
 * User: 86184
 * Date: 2023-09-26
 * Time: 9:39
 */
public class TestArrayList {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        String[] str= {"浩然1", "哈哈","浩然2","hello","java"};
        for(int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        //System.out.println(list);
        System.out.println("元素个数："+list.size());
        System.out.println(list.get(1));
        System.out.println("------------");
        for(int i = 0; i < list.size(); i++){
            System.out.println("下标："+i+","+list.get(i));
        }

        System.out.println("----------------");
        /**for(int i = 0; i < list.size(); i++){
            Object o = list.get(i);
            String s = (String)o;
            if(s.contains("然")){
                System.out.println(s);
            }
        }*/

        for(int i = 0; i < list.size(); i++){
            //Object o = list.get(i);
            String s = (String)list.get(i);
            if(s.contains("然")){
                System.out.println(s);
            }
        }

    }
}
